version: "3"

services:
  blog:
    container_name: blog
    command: >
      sh -c "poetry run python manage.py migrate &&
             poetry run python manage.py runserver 0.0.0.0:8000"
    build: .
    volumes:
      - .:/usr/src/blog
    ports:
      - "8000:8000"
    environment:
      - POSTGRES_DB=blog
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - SECRET_KEY=${SECRET_KEY}

  postgres:
    container_name: postgres
    image: postgres:latest
    environment:
      POSTGRES_DB: blog
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "5432:5432"
